package com.cad3d.filemanager.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.cad3d.filemanager.dao.Filemanagement;
import com.cad3d.filemanager.dbutils.FileManagementTableTool;
import com.opensymphony.xwork2.ActionSupport;

public class View3DFileAction extends ActionSupport implements ServletRequestAware{
	
	private Logger logger = Logger.getLogger(LoginAction.class);
	private int fileId;
	private String filePath;
	private HttpServletRequest servletRequest;
	
	public String execute() {
		logger.debug("fileId:::::::::::::::::: " + fileId);
		String 	contextStr = servletRequest.getSession().getServletContext().getContextPath();
		Filemanagement file = FileManagementTableTool.getInstance()
				.findFileById(fileId);
		filePath = contextStr + "/" + file.getFilePath();
		logger.debug("File name::::::::::::::: " + file.getFileName());
		logger.debug("File Path::::::::::::::: " + file.getFilePath());
		logger.debug("File Path absolutely::::::::::::::: " + filePath);
		return "success";
	}
	
	
	public int getFileId() {
		return this.fileId;
	}
	
	public void setFileId(int fileId) {
		this.fileId = fileId;
	}
	
	public String getFilePath() {
		return this.filePath;
	}
	
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	
	@Override
	public void setServletRequest(HttpServletRequest servletRequest) {
	    this.servletRequest = servletRequest;

	}
}
